<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>elementIsFocused</title>
</head>

<body>
    <input type="text" id="testInput" />
    <button type="button" id="testBtn">点击我</button>
    <script>
        const elementIsFocused = el => el === document.activeElement;
        const testBtn = document.getElementById('testBtn');
        const testInput = document.getElementById('testInput');
        testBtn.addEventListener('click', () => {
            testInput.focus();
            testInput.value = elementIsFocused(testInput);
        })
    </script>
</body>

</html>